<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>ES后台管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css">
	<link rel="stylesheet" href="__ADMIN__/css/frame.css" media="all" />
	<script type="text/javascript" src="__PUBLIC__/layui/layui.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/jquery-1.9.1.min.js"></script>
    
	
	
</head>
<body class="childrenBody" style="padding-bottom:40px;">

<style>
.upload-img-box img{float:left;padding:5px;}
</style>
<!--tab标签-->
    <div class="layui-tab-brief">

        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
            
                <form class="layui-form form-container"  data-url="<?php echo es_url('addonConfig'); ?>"  localtion-url="<?php echo es_url('addonList'); ?>">

                    <input type="hidden" name="id" value="<?php echo $list['id']; ?>" readonly>

       
        
         <?php if(empty($custom_config)): ?>
			<?php if(is_array($list['config'])): if( count($list['config'])==0 ) : echo "" ;else: foreach($list['config'] as $o_key=>$form): ?>
			<div class="layui-form-item">
			
			 <label style="width:<?php echo $form['labelwidth']; ?>" class="layui-form-label"><?php echo (isset($form['title']) && ($form['title'] !== '')?$form['title']:''); ?></label>
			  <div class="layui-input-inline">
			  <?php switch($form['type']): ?><?php case "text": ?>
							
								<input type="text" style="width:<?php echo $form['width']; ?>" name="config[<?php echo $o_key; ?>]" class="layui-input" value="<?php echo $form['value']; ?>">
							
							<?php break; ?>
							<?php case "password": ?>
							
								<input type="password" style="width:<?php echo $form['width']; ?>" name="config[<?php echo $o_key; ?>]" class="layui-input" value="<?php echo $form['value']; ?>">
							
							<?php break; ?>
							<?php case "hidden": ?>
								<input type="hidden" name="config[<?php echo $o_key; ?>]" value="<?php echo $form['value']; ?>">
							<?php break; ?>
							<?php case "radio": ?>
							
								<?php if(is_array($form['options'])): if( count($form['options'])==0 ) : echo "" ;else: foreach($form['options'] as $opt_k=>$opt): ?>
									
										<input type="radio" name="config[<?php echo $o_key; ?>]" value="<?php echo $opt_k; ?>"  title="<?php echo $opt; ?>"  <?php if($form['value'] == $opt_k): ?> checked<?php endif; ?>>
									
								<?php endforeach; endif; else: echo "" ;endif; ?>
							
							<?php break; ?>
							<?php case "checkbox": ?>
							
								<?php if(is_array($form['options'])): if( count($form['options'])==0 ) : echo "" ;else: foreach($form['options'] as $opt_k=>$opt): ?>
									
										<?php 
											is_null($form["value"]) && $form["value"] = array();
										 ?>
										<input type="checkbox" title="<?php echo $opt; ?>" name="config[<?php echo $o_key; ?>][]" value="<?php echo $opt_k; ?>"  <?php if(in_array(($opt_k), is_array($form['value'])?$form['value']:explode(',',$form['value']))): ?> checked<?php endif; ?>>
									
								<?php endforeach; endif; else: echo "" ;endif; ?>
							
							<?php break; ?>
							<?php case "select": ?>
							
								<select name="config[<?php echo $o_key; ?>]" class="layui-input"  >
									<?php if(is_array($form['options'])): if( count($form['options'])==0 ) : echo "" ;else: foreach($form['options'] as $opt_k=>$opt): ?>
										<option value="<?php echo $opt_k; ?>" <?php if($form['value'] == $opt_k): ?> selected<?php endif; ?>><?php echo $opt; ?></option>
									<?php endforeach; endif; else: echo "" ;endif; ?>
								</select>
							
							<?php break; ?>
							<?php case "textarea": ?>
							
								
									<textarea class="autosize layui-textarea" rows="<?php echo $form['rows']; ?>" cols="<?php echo $form['cols']; ?>" name="config[<?php echo $o_key; ?>]"><?php echo $form['value']; ?></textarea>
								
							
							<?php break; ?>
							
							<?php case "picture_union": ?>
								<input type="file" name="file" class="layui-upload-file" id="upload_picture_<?php echo $o_key; ?>" style="float: left;">
	                            
								<input type="hidden" name="config[<?php echo $o_key; ?>]" id="cover_id_<?php echo $o_key; ?>" value="<?php echo $form['value']; ?>"/>
								<div class="upload-img-box" >
									<?php if(!empty($form['value'])): ?>
									<?php  $mulimages = explode(",", $form["value"]);  ?>
									<?php if(is_array($mulimages)): if( count($mulimages)==0 ) : echo "" ;else: foreach($mulimages as $key=>$one): ?>
										<div class="upload-pre-item" val="<?php echo $one; ?>">
											<img width="100" height="70" src="<?php echo get_cover($one,'savepath'); ?>"  id="removePicture<?php echo $o_key; ?>"/>
										</div>
									<?php endforeach; endif; else: echo "" ;endif; ?>
									<?php endif; ?>
								</div>
								
								<script type="text/javascript">
							
								
								layui.use(['form', 'upload'],function(){
								  var form = layui.form
								  ,$ = layui.jquery;
								  
								  $('#removePicture<?php echo $o_key; ?>').click(function(){
									  var p = $(this).parent().parent();
										$(this).parent().remove();
										var ids = [];
										
										
										$("#cover_id_<?php echo $o_key; ?>").parent().find('.upload-img-box').find('.upload-pre-item').each(function(){
											ids.push($(this).attr('val'));
										});
										if(ids.length > 0)
											$("#cover_id_<?php echo $o_key; ?>").val(ids.join(','));
										else
											$("#cover_id_<?php echo $o_key; ?>").val('');
									  
									  
								  });
								  
								  
								  
								  layui.upload({
								    url: '<?php echo es_url("File/pictureUpload"); ?>'
								    ,elem:'#upload_picture_<?php echo $o_key; ?>'
								    ,before: function(input){
								    	
							
								      loading = layer.load(2, {
								        shade: [0.2,'#000']
								      });
								    }
								    ,success: function(res){
								      layer.close(loading);
										if(res.code==200){
											src = res.headpath;
											$("#cover_id_<?php echo $o_key; ?>").parent().find('.upload-img-box').append(
												'<div class="upload-pre-item" val="' + res.id + '"><img src="' + src + '" width="120" height="120"  id="removePicture<?php echo $o_key; ?>"/></div>'
											);
											var ids = [];
											
											
											$("#cover_id_<?php echo $o_key; ?>").parent().find('.upload-img-box').find('.upload-pre-item').each(function(){
												ids.push($(this).attr('val'));
											});
											if(ids.length > 0)
												$("#cover_id_<?php echo $o_key; ?>").val(ids.join(','));
											else
												$("#cover_id_<?php echo $o_key; ?>").val('');
										} else {
											
											 layer.msg(data.msg, {icon: 1, time: 1000});
										
										}
								    
								     
								    }
								  }); 


								})
								
								
								
								</script>
					
							<?php break; ?>
							
							
							
							
							
							
							<?php endswitch; ?>
							
							
							<div class="layui-form-mid layui-word-aux">
						<?php if(isset($form['tip'])): ?>
							<?php echo $form['tip']; ?>
						<?php endif; ?>
						</div>
							
							</div>
							
						
	
			
			</div>
		
			<?php endforeach; endif; else: echo "" ;endif; ?>
		<?php else: ?>
			<?php if(isset($custom_config)): ?>
				<?php echo $custom_config; ?>
			<?php endif; ?>
		<?php endif; ?>

 <div class="btable-paged" >
                 <div class="layui-main">
                    <div class="formbtngroup">
<button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="formadd">提交</button>
<a href="javascript:;"  class="layui-btn layui-btn-primary layui-btn-sm closebtn">返回</a>
</div>
</div>
     </div>        
    </form>
   </div>
        </div>
    </div>
    
  


	
	
	<script type="text/javascript" src="__ADMIN__/js/main.js"></script>
		
	
<!--页面JS脚本-->

</body>
</html>